<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('alarms', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable(true)->comment('告警名');
            $table->unsignedBigInteger('e_s_cluster_id')->nullable(true)->comment('所属储能簇id');
            $table->string('type')->nullable(true)->comment('类别');
            $table->enum('level', ['normal', 'light', 'moderate','severe'])->default('light')->comment('水平');
            $table->timestamps();
        });
        //预警
        Schema::create('early_alarms', function (Blueprint $table) {
            $table->id();
            $table->string('item')->nullable(true)->comment('诊断项目');
            $table->string('suggestion')->nullable(true)->comment('建议');
            $table->json('result')->nullable(true)->comment('预测结果(json)');
            $table->string('effect')->nullable(true)->comment('预警效果');
            $table->enum('level', ['normal', 'light', 'moderate','severe'])->default('light')->comment('水平');
            $table->unsignedBigInteger('e_s_cluster_id')->comment('所属储能簇id');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('alarms');
        Schema::dropIfExists('early_alarms');
    }
};
